// test.ts

import type { MockMethod, MockConfig } from 'vite-plugin-mock'
export default [
	{
		url: '/api/application',
		method: 'get',
		response: ({ query }: { query: Record<string, any> }) => {
			return {
				code: 200,
				data: [
					{
						id: 1,
						name: '竞技体育'
					},
					{
						id: 2,
						name: '公共服务平台'
					}
				]
			}
		}
	},
	{
		url: '/api/workflow/list',
		method: 'get',
		timeout: 2000,
		response: {
			code: 200,
			data: {
				row: [
					{
						id: 1935952739491200,
						createBy: '1',
						createName: '管理员',
						createTime: '2024-12-23 10:11:53',
						updateBy: '1',
						updateName: '管理员',
						updateTime: '2025-09-15 13:36:10',
						valid: 1,
						tenantId: 'test_a',
						schemeDetailId: 1936306520954048,
						deploymentId: 1936306521265344,
						modelId: 1935949934902656,
						name: '积分兑换',
						code: 'prevention-jfdh',
						applicationName: 'hbt-prevention',
						description: '',
						enabled: 1
					},
					{
						id: 1935978214751616,
						createBy: '1',
						createName: '管理员',
						createTime: '2024-12-23 11:55:32',
						updateBy: '1',
						updateName: '管理员',
						updateTime: '2024-12-23 18:57:24',
						valid: 1,
						tenantId: 'test_a',
						schemeDetailId: 1936081893033152,
						deploymentId: 1936081893729472,
						modelId: 1935969181588864,
						name: '隐患治理',
						code: 'prevention-yhzl',
						applicationName: 'hbt-prevention',
						description: '',
						enabled: 1
					}
				]
			}
		}
	},
	{
		url: '/api/text',
		method: 'post',
		rawResponse: async (req, res) => {
			let reqbody = ''
			await new Promise(resolve => {
				req.on('data', chunk => {
					reqbody += chunk
				})
				req.on('end', () => resolve(undefined))
			})
			res.setHeader('Content-Type', 'text/plain')
			res.statusCode = 200
			res.end(`hello, ${reqbody}`)
		}
	}
] as MockMethod[]
